import { Component } from "@angular/core";
import { createComponent } from "../dialog/create.component";
import { DialogService } from "ng-devui";

@Component({
  selector:'test-icon',
  templateUrl:'./test-icon.component.html',
  styleUrls:['./test-icon.component.scss']
})

export class TestIconComponent{
  constructor(private dialogService: DialogService) {
    console.log("TestIconComponent");
  };
  config = {
    id: 'dialog-service',
    width: '346px',
    maxHeight: '600px',
    title: 'Start Snapshot Version',
    content: createComponent,
    backdropCloseable: true,
    onClose: () => console.log('on dialog closed'),
    data: {
      name: 'Tom',
      age: 10,
      address: 'Chengdu',
    },
  };
  openDialog(dialogtype?: string, showAnimation?: boolean) {
    const results = this.dialogService.open({
      ...this.config,
      showMaximizeBtn: true,
      dialogtype: dialogtype,
      showAnimation: showAnimation,
      buttons: [
        {
          cssClass: 'primary',
          text: 'Ok',
          disabled: false,
          handler: ($event: Event) => {
            results.modalInstance.hide();
          },
        },
        {
          id: 'btn-cancel',
          cssClass: 'common',
          text: 'Cancel',
          handler: ($event: Event) => {
            results.modalInstance.hide();
          },
        },
      ],
    });
    console.log(results);
    (document.getElementsByClassName("modal")[0] as any).style["maxWidth"]="100vw";
  }
}
